<template>
    <div id="Activity">
        <el-row>
            <el-col :span="16" :offset="4">
            	<el-breadcrumb class="breadcrumb" separator-class="el-icon-arrow-right">
				  <el-breadcrumb-item :to="{ path: '/' }">玖玖盈</el-breadcrumb-item>
				  <el-breadcrumb-item>活动</el-breadcrumb-item>
				</el-breadcrumb>
                <el-row :gutter="20">
                    <el-col :span="8">
                    	<ul class="video-list">
                            <li v-for="(article, i) in activity" :key="i">
                            	<router-link class="article-target" :to="'/activityDetail?id=' + article.articleId">
                            		<div class="article-title">{{article.articleTitle}}</div>
                                    <div class="article-time">{{formatTime(article.time)}}</div>
                            	</router-link>
                            </li>
                        </ul>
                    </el-col>
                    <el-col :span="16">
                        <ul class="banner-list">
                            <li v-for="(banner, i) in bannerList" :key="i">
                                <div class="banner">
                                    <img class="banner-img" :src="UPLOAD_URL + banner.imageUrl" alt="">
                                </div>
                                <div class="qr">
                                    <img class="qr-img" :src="UPLOAD_URL + banner.qrCodeUrl" alt="">
                                    <div class="tips">扫描二维码了解详情</div>
                                </div>
                            </li>
                        </ul>
                    </el-col>
                </el-row>
                <el-pagination @current-change="currentChange" :current-page.sync="pageId" :page-size="pageSize" layout="prev, pager, next, jumper" :total="count" class="x-paginations">
                </el-pagination>
            </el-col>
        </el-row>
    </div>
</template>
<script>
import {getArticle, getBanner} from '@/api/api'
export default {
	data: function(){
		return {
			activity: null,
			pageSize: 10,
            pageId: 1,
            count: 0,
            bannerList: []
		}
	},
	created: function(){
        this.pageId = parseInt(this.$route.query.pageId) || 1;
        this.getActivity()
		this.getBanners()
	},
	methods: {
        getBanners: function(){
            getBanner({params: {pageId: 1, pageSize: 3}}).then(res =>{
                this.bannerList = res.list;
            })
        },
		getActivity: function(){
			getArticle({articleCategoryType: 'activity', pageSize: this.pageSize, pageId: this.pageId}).then(res => {
				console.log(res)
				this.activity = res.list;
				this.count = parseInt(res.count);
			})
		},
		currentChange: function(val) {
            this.$router.push('?pageId=' + val)
            this.pageId = val;
            this.getActivity()
        },
        formatTime: function(time) {
            var date = new Date(time);
            var year = date.getFullYear();
            var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1);
            var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
            var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
            var mins = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
            var sec = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
            return year + '-' + month + '-' + day + ' ' + hours + ':' + mins + ':' + sec;
        }
	}
}
</script>
<style scoped>
.video-list,
.banner-list {
    list-style: none;
    padding-left: 0;
}

.video-list li {
    line-height: 30px;
    margin: 10px 0;
    padding: 5px;
    border: 1px solid #c5c0c0;
    border-radius: 2px;
    transition: all .3s linear;
}
.banner-list li{
    margin: 10px 0;
    padding: 5px;
    border: 1px solid #c5c0c0;
    border-radius: 2px;
    transition: all .3s linear;
    position: relative;
}
.article-target {
    width: 100%;
    height: 100%;
    display: block;
    text-decoration: none;
    transition: all .3s linear;
    color: #5a5f67;
}

.video-list li:hover,
.banner-list li:hover {
    box-shadow: 0 3px 18px 0 rgba(0, 0, 0, .3);
}

.video-list li:hover .article-target {
    color: #c32525;
}

.article-time{
    font-size: 14px;
}
.banner{
    font-size: 0;
}
.banner:before{
    content: '';
    display: block;
    width: 120px;
    height: 120px;
    background: url(../assets/hot.png) no-repeat center;
    background-size: cover;
    position: absolute;
    left: 5px;
    top: 1px;
}
.banner-img{
    width: 100%;
}
.qr{
    width: 100%;
    height: 100%;
    padding: 40px 0;
    box-sizing: border-box;
    opacity: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    text-align: center;
    transform: translate(-50%, -50%);
    transition: all .3s linear;
}
.qr img{
    height: 100%;
}
.banner-list li:hover .qr{
    opacity: 1;
    background-color: rgba(0, 0, 0, .7);
    z-index: 9999;
}
.tips{
    color: #fff;
    font-size: 14px;
}
</style>
